// 用来设置和获取 删除 localStorage 存储
let local = {
    setStore (key, value) {
        if (typeof value === 'string') {
            localStorage.setItem(key, value)
        } else {
            localStorage.setItem(key, JSON.stringify(value))
        }
    },
    getStore (key) {
        // let list = localStorage.getItem(key)
        // if (list && (new Date().getTime() > (JSON.parse(list).time + (10 * 1000)))) {
        //     localStorage.removeItem(key)
        //     list = localStorage.getItem(key)
        // }
        return (localStorage.getItem(key) && JSON.parse(localStorage.getItem(key))) || []
    },
    del (key) {
        if (key) {
            localStorage.removeItem(key)
        } else {
            localStorage.clear()
        }
    }
}
export default {
    install: function (vm) {
        vm.prototype.$local = local
    },
    local
}
// 使用 this.$local.setStore()
